// JavaScript Document
//用户登录
(function($) {
	$.PageModel = function() {
		this.recordCount = 0;
		this.pageCount = 0;
		this.curPageNum = 1;
		this.pageSize = 1;
		this.start = 0;
		this.limit = 5;
		this.msg = "";
		
		this.setTotalRecordCount = function(rCount) {
			this.recordCount = rCount;
			this.pageCount = parseInt((rCount + this.pageSize - 1) / this.pageSize);
			
			this.msg = "当前第【" + this.curPageNum + "】页，共【" + this.pageCount + "】页";
		}
		
		this.initDefault = function() {
			this.start = 0;
			this.limit = 5;
			this.pageSize = 5;
			this.pageCount = 1;
			this.curPageNum = 1;
			this.recordCount = 0;
		}

		this.setPageSize = function(pSize) {
			this.pageSize = pSize;
			this.limit = pSize;
		}
		
		this.initParam = function(rCount, pSize) {
			this.recordCount = rCount;
			this.pageSize = pSize;
			this.limit = pSize;
			this.curPageNum = 1;
			this.pageCount = parseInt((rCount + pSize - 1) / pSize);
		}
		
		this.nextPage = function() {
			if(this.curPageNum < this.pageCount) {
				this.curPageNum++;				
			}
			this.msg = "当前第【" + this.curPageNum + "/" + this.pageCount + "】页";
			this.start = this.pageSize * (this.curPageNum - 1);
		}
		
		this.prevPage = function() {
			if(this.curPageNum > 1) {
				this.curPageNum--;
			}
			this.msg = "当前第【" + this.curPageNum + "/" + this.pageCount + "】页";
			this.start = this.pageSize * (this.curPageNum - 1);
		}
		
		this.firstPage = function() {
			this.curPageNum = 1;
			this.msg = "当前第【" + this.curPageNum + "/" + this.pageCount + "】页";
			this.start = this.pageSize * (this.curPageNum - 1);
		}
		
		this.lastPage = function() {
			this.curPageNum = this.pageCount;
			this.msg = "当前第【" + this.curPageNum + "/" + this.pageCount + "】页";
			this.start = this.pageSize * (this.curPageNum - 1);
		}
		
		this.getPages = function() {
			return this.pageCount;
		}
		
		this.getStart = function() {
			return this.start;
		}
		
		this.getLimit = function() {
			return this.limit;
		}
		
		this.getMsg = function() {
			return this.msg;
		}
		
	}
})(jQuery);
var pageModel = new $.PageModel();
